package com.sjms._10_结构_组合模式;

import java.util.ArrayList;

/**
 * 目录
 */
public class Directory extends ANode {
    ArrayList<ANode> nodeList = new ArrayList<>();

    public Directory(String name, String path, int level) {
        super(name, path, level);
    }

    @Override
    void add(ANode obj) {
        this.nodeList.add(obj);
    }

    @Override
    void remove(int index) {
        this.nodeList.remove(index);
    }

    @Override
    void print() {
        //输出层级
        for (int j = 0; j < level; j++) {
            System.out.print("    ");
        }
        System.out.println("-" + this.name);

        for (int i = 0; i < this.nodeList.size(); i++) {
            ANode aNode = this.nodeList.get(i);
            aNode.print();
        }

    }

}
